//
//  YIem_Find_Found_Sub_ViewController.m
//  B段_开眼
//
//  Created by YIem on 16/4/27.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_Find_Found_Sub_ViewController.h"

@interface YIem_Find_Found_Sub_ViewController ()
@property (nonatomic, strong) UISegmentedControl *seg;
@property (nonatomic, strong) YIem_FindDetail_Share_ViewController *shareView;
@property (nonatomic, strong) YIem_FindDetail_Time_ViewController *timeView;
@end

@implementation YIem_Find_Found_Sub_ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
//    NSLog(@"%@", self.model.name);
    self.view.backgroundColor = [UIColor whiteColor];
    // 返回
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_back_normal"] style:UIBarButtonItemStylePlain target:self action:@selector(leftAction)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithRed:0.2077 green:0.2077 blue:0.2077 alpha:1.0];



    
    
    self.shareView = [[YIem_FindDetail_Share_ViewController alloc] init];
    self.shareView.urlStr = [NSString stringWithFormat:@"http://baobab.wandoujia.com/api/v3/pgc/videos?&num=20&pgcId=%@&start=0&strategy=date", self.model.ID];
    [self addChildViewController:self.shareView];
    [self.view addSubview:self.shareView.view];
    
    self.timeView = [[YIem_FindDetail_Time_ViewController alloc] init];
    self.timeView.urlStr = [NSString stringWithFormat:@"http://baobab.wandoujia.com/api/v3/pgc/videos?&num=20&pgcId=%@&start=0&strategy=shareCount", self.model.ID];
    [self addChildViewController:self.timeView];
    [self.view addSubview:self.timeView.view];

    
    self.seg = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"按时间排序", @"分享排行榜", nil]];
    //    self.seg = [[UISegmentedControl alloc] init];
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName,[UIFont fontWithName:@"AppleGothic"size:18],NSFontAttributeName ,nil];
    
    [self.seg setTitleTextAttributes:dic forState:UIControlStateNormal];
    self.seg.selectedSegmentIndex = 0;
    self.seg.backgroundColor = [UIColor whiteColor];
    self.seg.tintColor = [UIColor clearColor];
    
    //    self.seg.alpha = 0.2;
    
    self.seg.frame = CGRectMake(0, 64, self.view.frame.size.width, 40);
    [self.seg addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:self.seg];
    

    
}

- (void)segAction:(UISegmentedControl *)sender
{
    if (0 == sender.selectedSegmentIndex) {
        
        [self.view bringSubviewToFront:self.timeView.view];
    }else {
        
        [self.view bringSubviewToFront:self.shareView.view];
    }
    [self.view bringSubviewToFront:self.seg];
}






- (void)leftAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
